import { moveUp, moveDown } from './../../store/utils/project';
import { deleteSelf } from '@/store/utils/project';
import { Modal } from 'ant-design-vue';
import hotkeys from 'hotkeys-js';
import { setCopyInfo, pasteCopyInfo } from './bin';
import { treeBus } from './treeData';
/**
 * todo:方法描述
 *  */
export const shortKey = () => {
    hotkeys("F2", (event) => {
        event.preventDefault();
        var selectItem = treeBus.selectItem;
        selectItem.editable = true;
    });
    hotkeys("ctrl+s", (event: Event) => {
        event.preventDefault();
    });
    hotkeys("delete", (event) => {
        event.preventDefault();
        var selectItem = treeBus.selectItem;
        Modal.confirm({
            content: "是否要删除此项",
            onOk() {
                deleteSelf(selectItem);
            },
            closable: true
        });
    });
    hotkeys("enter", () => {
        var selectItem = treeBus.selectItem;
        selectItem.expand = !selectItem.expand;
    })
    hotkeys("ctrl+c", () => {
        var selectItem = treeBus.selectItem;
        setCopyInfo(selectItem)
    })
    hotkeys("ctrl+v", () => {
        pasteCopyInfo()
    })
    hotkeys("up", () => {
        moveUp(treeBus.selectItem)
    })
    hotkeys("down", () => {
        moveDown(treeBus.selectItem)
    })
}